/**
 * 
 */
package fr.univ_tln.inf9.exaplanning.controleur.facade;

import java.util.List;

import fr.univ_tln.inf9.exaplanning.api.administration.Administrator;
import fr.univ_tln.inf9.exaplanning.api.composante.Component;
import fr.univ_tln.inf9.exaplanning.api.facade.University;
import fr.univ_tln.inf9.exaplanning.api.salle.Building;
import fr.univ_tln.inf9.exaplanning.api.utilisateur.Student;
import fr.univ_tln.inf9.exaplanning.api.utilisateur.Teacher;
import fr.univ_tln.inf9.exaplanning.gui.facade.JFrameListAdmin;
import fr.univ_tln.inf9.exaplanning.gui.facade.JFrameListBuilding;
import fr.univ_tln.inf9.exaplanning.gui.facade.JFrameListComponent;
import fr.univ_tln.inf9.exaplanning.gui.facade.JFrameListStudent;
import fr.univ_tln.inf9.exaplanning.gui.facade.JFrameListTeacher;


/**
 * @author pivi
 *
 */
public class UniversityController {
	
	//public UniversityView listBuildingView = null;
	//public UniversityView listAdminView = null;
	public UniversityView listStudentView = null;
	public UniversityView listTeacherView = null;
	//public UniversityView listComponentView = null;
	
	
	
	
	private University univ = null;
	
	public UniversityController (University univ){
		this.univ = univ;
		
		//listBuildingView = new JFrameListBuilding(this,univ.getLbuilding());
		//listAdminView = new JFrameListAdmin(this,univ.getLadmin());
		listStudentView = new JFrameListStudent(this,univ.getLstudent());
		listTeacherView = new JFrameListTeacher(this,univ.getLteach());
		//listComponentView = new JFrameListComponent(this,univ.getLcomponent());
		
		
		
		addListenersToListTeacher();
		addListenersToListStudent();
		addListenersToListAdmin();
		addListenersToListBuilding();
		addListenersToListComponent();
	}
	
	private void addListenersToListComponent() {
		//univ.AddListComponentListener(listComponentView);
	}

	private void addListenersToListBuilding() {
		//univ.AddListBuildingListener(listBuildingView);
	}

	private void addListenersToListAdmin() {
		//univ.AddListAdminListener(listAdminView);
	}

	private void addListenersToListStudent() {
		univ.AddListStudentListener(listStudentView);
	}

	private void addListenersToListTeacher() {
		univ.AddListTeacherListener(listTeacherView);
	}

	
	public void displayViews(){
		//listBuildingView.display();
		//listAdminView.display();
		listStudentView.display();
		listTeacherView.display();
		//listComponentView.display();
	}
	
	public void closeViews(){
		//listBuildingView.close();
		//listAdminView.close();
		listStudentView.close();
		listTeacherView.close();
		//listComponentView.close();
	}
	
	/**
	 * Notification sur tous les changements paossibles sur une liste
	 * @param ladm
	 */
	public void notifyListAdminChanged(List<String> ladm){
		univ.setLadmin(ladm);
	}
	
	public void notifyAdminAddedToList(Administrator a){
		univ.addAdmin(a);
	}
	
	
	public void notifyAdminRemovedToList(String nameA){
		univ.removeAdmin(nameA);
	}
	
	
	public void notifyListStudentChanged(List<String> lstudent){
		univ.setLstudent(lstudent);
	}
	
	public void notifyStudentAddedToList(Student s){
		univ.addStudent(s);
	}
	
	
	public void notifyStudentRemovedToList(String mailS){
		univ.removeStudent(mailS);
	}
	
	public void notifyListTeacherChanged(List<String> lteach){
		univ.setLteach(lteach);
	}
	
	public void notifyTeacherAddedToList(Teacher t){
		univ.addTeach(t);
	}
	
	
	public void notifyTeacherRemovedToList(String mailT){
		univ.removeTeach(mailT);
	}
	
	public void notifyListBuildingChanged(List<String> lbuilding){
		univ.setLbuilding(lbuilding);
	}
	
	public void notifyBuildingAddedToList(Building b){
		univ.addBuilding(b);
	}
	
	
	public void notifyBuildingRemovedToList(String nameB){
		univ.removeBuilding(nameB);
	}
	
	public void notifyListComponentChanged(List<String> lcomponent){
		univ.setLcomponent(lcomponent);
	}
	
	public void notifyComponentAddedToList(Component c){
		univ.addComponent(c);
	}
	
	
	public void notifyComponentRemovedToList(String nameC){
		univ.removeComponent(nameC);
	}

}
